<!DOCTYPE html>
<html>
<body>
<input type="text" id="text1" placeholder="字符串1" oninput="countR()">
<input type="text" id="text2" placeholder="字符串2" oninput="countR()">
<p>r的数量：<span id="count">0</span></p>

<script>
function countR() {
  const str1 = document.getElementById('text1').value;
  const str2 = document.getElementById('text2').value;
  const total = (str1.match(/r/g) || []).length + 
                (str2.match(/r/g) || []).length;
  document.getElementById('count').textContent = total;
}
</script>
</body>
</html>